package com.xoa.controller.attend;

import com.xoa.model.attend.AttendanceOvertime;
import com.xoa.model.attend.AttendanceOvertimeFlowRunPrcs;
import com.xoa.service.attend.AttendanceOvertimeService;
import com.xoa.util.ToJson;
import com.xoa.util.common.wrapper.BaseWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created by gsb on 2017/11/22.
 */
@Controller
@RequestMapping("/attendanceOvertime")
public class AttendanceOvertimeController {

    @Resource
    private AttendanceOvertimeService attendanceOvertimeService;
    /**
     * 创建人：季佳伟
     * 创建时间：2017-11-21  下午5:40:17
     * 方法介绍：查询登录人一段时间内的加班状况
     * 参数说明：
     */
    @RequestMapping(value = "/queryAttendanceOvertimeByUserId", produces = { "application/json;charset=UTF-8" })
    @ResponseBody
    public ToJson<AttendanceOvertime> queryAttendanceOvertimeByUserId(String beginDate, String endDate, HttpServletRequest req){
        return attendanceOvertimeService.queryAttendanceOvertimeByUserId(beginDate, endDate, req);
    }

    @RequestMapping(value = "/addAttendanceOvertime", produces = { "application/json;charset=UTF-8" })
    @ResponseBody
    public BaseWrapper addAttendanceOvertime(String createDate, HttpServletRequest request){
        return attendanceOvertimeService.addAttendanceOvertime(createDate,request);
    }

    /**
     * 创建作者:   张丽军
     * 创建日期:   2018-9-29 下午16:45:00
     * 方法介绍:   查询加班登记
     */
    @ResponseBody
    @RequestMapping(value = "/queryAllAttendOut", produces = { "application/json;charset=UTF-8" })
    ToJson<AttendanceOvertimeFlowRunPrcs> queryAllAttendOut(@RequestParam(name = "page", required = false, defaultValue = "1") Integer page,
                                                            @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                                            @RequestParam(name = "useFlag", required = false, defaultValue = "true") Boolean useFlag,
                                                            String allow, HttpServletRequest request){
        return attendanceOvertimeService.queryAllAttendanceOvertime(page,pageSize,useFlag,request,allow);
    }


    /**
     * 加班登记删除操作
     * @param overtimeId
     * @return
     */
    @RequestMapping(value = "/deleteAttendanceOvertime")
    @ResponseBody
    public ToJson deleteAttendanceOvertimeById(Integer overtimeId){
        return attendanceOvertimeService.deleteAttendanceOvertimeById(overtimeId);
    }

    /**
     * 加班登记修改操作
     * @param attendanceOvertime
     * @return
     */
    @RequestMapping(value = "/updateAttendanceOvertime")
    @ResponseBody
    public ToJson updateAttendanceOvertime(AttendanceOvertime attendanceOvertime){
        return attendanceOvertimeService.updateAttendanceOvertime(attendanceOvertime);
    }

    /**
     * 查询最近3个月的加班
     * @param userId
     * @return
     */
    @RequestMapping(value = "/selectAllAttendanceOvertimes")
    @ResponseBody
    public ToJson selectAttendanceOvertimeByUserId(String userId){
        return attendanceOvertimeService.selectAttendanceOvertimeByUserId(userId);
    }
    }
